﻿Public Class modify_password

    Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        

        If TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox1.Text = "" Then
            MsgBox("Supply all Fields")
        Else
            rs = New ADODB.Recordset
            rs.Open("SELECT * from Account where username = '" & TextBox4.Text & "'", cn, 3, 2)
            If TextBox1.Text = rs.Fields("password").Value Then
                If TextBox2.Text.Equals(TextBox3.Text) Then
                    If TextBox2.Text.Length < 11 And TextBox2.Text.Length > 3 Then
                        rs = New ADODB.Recordset
                        rs.Open("SELECT * from Account where username = '" & TextBox4.Text & "'", cn, 3, 2)
                        rs.Fields("password").Value = TextBox2.Text
                        rs.Update()
                        rs.Close()
                        rs = Nothing
                        MsgBox("Successfully Updated")
                        MainScreen.Show()
                        Me.Close()
                    Else
                        MsgBox("Password should be 4 to 10 characters long")
                    End If

                Else
                    MsgBox("2 Password Inputs are Not Equal")
                End If
            Else
                MsgBox("The current password you have entered is wrong")
            End If


        End If






    End Sub

    Private Sub modify_password_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Module1.connect()
        TextBox4.Enabled = False
        rs = New ADODB.Recordset
        rs.Open("SELECT * from account", cn, 3, 2)
        If Not rs.EOF Then
            TextBox4.Text = rs.Fields("username").Value
        End If
        rs.Close()
        rs = Nothing

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        accountmgnt.Show()
        Me.Close()

    End Sub

    Private Sub modify_password_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

    End Sub
End Class